package com.bupt.inklue.controller;

import com.bupt.inklue.dto.UserDTO;
import com.bupt.inklue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping
    public boolean add(@RequestBody UserDTO userDTO) {
        return userService.add(userDTO);
    }

    @DeleteMapping
    public boolean delete(@RequestBody UserDTO userDTO) {
        return userService.delete(userDTO);
    }

    @PutMapping
    public boolean edit(@RequestBody UserDTO userDTO) {
        return userService.edit(userDTO);
    }

    @GetMapping("{account}")
    public UserDTO get(@PathVariable String account) {
        return userService.getByAccount(account);
    }
}
